// AnsiTerminalDoc.h : interface of the CAnsiTerminalDoc class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_ANSITERMINALDOC_H__35A860B5_69DD_4EF2_B834_5E59953A6536__INCLUDED_)
#define AFX_ANSITERMINALDOC_H__35A860B5_69DD_4EF2_B834_5E59953A6536__INCLUDED_

/*
#include "TelnetLayer.h"
*/
#include "TelnetLayerEvents.h"
#include "TelnetLayer.h"
#include "AnsiLayer.h"
#include "AnsiScreen.h"
#include "TelnetLogger.h"
#include "SessionOptions.h"
#include "StandardKeyboard.h"
#include "VT220KeyMap.h"
#include "StandardMouse.h"
#include "BbsLayer.h"

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


class CAnsiTerminalDoc : public CDocument
{
private:
	class TelnetLayerEvents : public CTelnetLayerEvents
	{
	private:
		CAnsiTerminalDoc *m_pDoc;
	public:
		TelnetLayerEvents(CAnsiTerminalDoc* pDoc)
		{
			m_pDoc = pDoc;
		}
		virtual void OnSocketClosed()
		{
			m_pDoc->m_telnetLayer.Disconnect();
		}
	} m_telnetLayerEvents;
	friend class TelnetLayerEvents;

private:
	CAnsiScreen m_ansiScreen;
	CAnsiLayer m_ansiLayer;
	CTelnetLayer m_telnetLayer;
	CTelnetLogger m_telnetLogger;
	CSessionOptions m_options;
	CStandardKeyboard m_keyboard;
	CVT220KeyMap m_keyMap;
	
	CBbsLayer m_bbsLayer;
	CStandardMouse m_mouse;

	void ShowLog();

protected: // create from serialization only
	CAnsiTerminalDoc();
	DECLARE_DYNCREATE(CAnsiTerminalDoc)

// Attributes
public:
	CSessionOptions& GetOptions();
	CAnsiScreen& GetScreen();
	IVirtualKeyboard* GetKeyboard();
	IVirtualMouse* GetMouse();
	CTelnetLayer& GetTelnetLayer();

// Operations
public:
	void ReConnect();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAnsiTerminalDoc)
	public:
	virtual BOOL OnNewDocument();
	virtual void Serialize(CArchive& ar);
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CAnsiTerminalDoc();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CAnsiTerminalDoc)
	afx_msg void OnConnect();
	afx_msg void OnUpdateConnect(CCmdUI* pCmdUI);
	afx_msg void OnAppAbout();
	afx_msg void OnFilePrintPreview();
	afx_msg void OnFilePrint();
	afx_msg void OnWriteLog();
	afx_msg void OnClearLog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

	// Generated OLE dispatch map functions
	//{{AFX_DISPATCH(CAnsiTerminalDoc)
		// NOTE - the ClassWizard will add and remove member functions here.
		//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_DISPATCH
	DECLARE_DISPATCH_MAP()
	DECLARE_INTERFACE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_ANSITERMINALDOC_H__35A860B5_69DD_4EF2_B834_5E59953A6536__INCLUDED_)
